package com.wantupai.mvp.framework.support.viewstate.fragment;

import android.support.annotation.NonNull;

import com.wantupai.mvp.framework.support.fragment.FragmentMvpDelegateImpl;
import com.wantupai.mvp.framework.support.viewstate.MvpViewStateDelegateCallback;
import com.wantupai.mvp.framework.support.viewstate.ViewState;
import com.wantupai.mvp.mvp.MvpPresenter;
import com.wantupai.mvp.mvp.MvpView;
import com.wantupai.mvp.mvp.lce.fragment.MvpFragment;


public abstract class MvpViewStateFragment<D, V extends MvpView<D>, P extends MvpPresenter<V>, VS extends ViewState<V>> extends MvpFragment<D, V, P> implements MvpViewStateDelegateCallback<V, P, VS>
{
    private VS viewState;

    @Override
    protected FragmentMvpDelegateImpl<V, P> getMvpDelegate()
    {
        if (mvpDelegate == null)
        {
            mvpDelegate = new FragmentMvpViewStateDelegateImpl<>(this, this, true, true);
        }
        return super.getMvpDelegate();
    }

    @Override
    public VS getViewState()
    {
        return viewState;
    }

    @Override
    public void setViewState(VS viewState)
    {
        this.viewState = viewState;
    }

    @NonNull
    @Override
    public VS createViewState()
    {
        return viewState;
    }

    @Override
    public void setRestoringViewState(boolean restoringViewState)
    {
    }

    @Override
    public void onViewStateInstanceRestored(boolean instanceStateRetained)
    {

    }

    @Override
    public void onNewViewStateInstance()
    {

    }
}
